<%@ page language="java" import="java.util.*" contentType="text/html"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>课程资料选择</title>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>' />
<script src='<c:url value="/js/boot.js"></c:url>'></script>
<script src='<c:url value="/js/rqfui/rqfui.js"></c:url>'></script>
<style type="text/css">
body, html {
	width: 100%;
	height: 100%;
	margin: 0;
	font-family: "微软雅黑";
}

p {
	margin-left: 5px;
	font-size: 14px;
}

body {
	height: 100%;
	overflow: hidden;
}

.filterPan td {
	padding: 0;
}

.mini-splitter-pane {
	overflow: auto;
}

.mini-panel-body {
	padding: 0;
}

html body .searchbox .mini-buttonedit-icon {
	background: url('<c:url value="/share/img/magnifier-zoom.png"></c:url>')
		no-repeat 5% 5%;
}

.nameTitle {
	color: red;
}
</style>
</head>

<body>
		<div><a class="mini-button"  id="okBtn"iconCls="icon-ok" tooltip="确定" onclick="selected()">确定
		</a></div>
		<div class="mini-fit">
				<div id="datagrid1" class="mini-datagrid gridFull"
					borderStyle="border:1;" showReloadButton="true" pagesize="100"
					sizeList="[20,50,100,200]" allowCellWrap="true"
					allowHeaderWrap="true" idField="No" multiSelect="true"
					showPager="true" allowAlternating="true"
					ondrawcell="ondatagrid1DrawCell" onrowdblclick="gridRowDbClick"
					style="height: 100%; width: 100%; -moz-user-select: none; -webkit-user-select: none;"
					collapseGroupOnLoad="false" showColumnsMenu="true"
					showFilterRow="true" onshowrowdetail="onShowRowDetail">
					<div property="columns">
						<div type="indexcolumn" width="40px"></div>
						<div type="checkcolumn" width="60px">
						</div>
						<div field="Action" width="70px" headerAlign="center"
							align="center">
							<a class="mini-button" property="filter" id="removeBtn"
								iconCls="icon-broom" tooltip="清除筛选" onclick="removeSearch_2">清除
							</a>
						</div>
						<div field="source_name" width="200px" headerAlign="center"
							align="left" allowSort="true">
							资料名称<input id="filter1" property="filter"
								class="mini-buttonedit searchbox" style="width: 100%;"
								onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="type" width="100px" headerAlign="center"
							align="center" allowSort="true">
							资料形式
						</div>
						<div field="creater" width="65px" headerAlign="center"
							align="center" allowSort="true">
							上传者<input id="filter2" property="filter"
							class="mini-buttonedit searchbox" style="width: 100%;"
							onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="createTime" width="185px" dateFormat="yyyy-MM-dd hh:mm:ss"
							headerAlign="center" align="center" allowSort="true">上传日期</div>
						<!-- <div field="operation" width="100px"
							headerAlign="center" align="center" allowSort="true"></div> -->
						<div name="emptyCol" width='100%' headerAlign="center"
							align="center" cellStyle="padding:0;"></div>
					</div>
				</div>
	</div>
	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		var isKeepStat3 = false;
		var rootPath = '${rootPath}';
		var type = '${type}';
		var filterHelper = gridFilter();
		var datagrid1 = mini.get("datagrid1");
		var splitpan = mini.get("splitterPan");
		var filter1 = mini.get("filter1");
		var filter2 = mini.get("filter2");
		var filter3 = mini.get("filter3");

		$(function() {
			loadGrid1();
		});
		function onselect(){
			
		}
		function loadGrid1() {
			var filterData = filterHelper.getFilterData();
			var postData = new Object();
			if (filterData != null || filterData.length > 0) {
				postData.filterdata = mini.encode(filterData);
			}
			var url = "<c:url value='/source/list/' />" + type;
			datagrid1.load(url);
			datagrid1.load(postData);
		}
		function removeSearch() {
			filter1.setValue();
			filter1.setText();
			filter2.setValue();
			filter2.setText();
			filter3.setValue();
			filter3.setText();
			filterHelper.clearFilterData();
			loadGrid1();

		}
		function ondatagrid1DrawCell(e) {
			var row = e.row;
			var field = e.field;
			if (field == "type") {
				if(row.type == 1){                                                                                                                                                                   
					e.cellHtml="图文";
				}
				if(row.type == 2){
					e.cellHtml="音频";
				}
				if(row.type == 3){
					e.cellHtml="视频";
				}
			}

		}
		function selected(){
			var ids = datagrid1.getSelecteds();
			if(ids.length>1){
				mini.alert("只能选择一个文件！");
			}else{
				//parent.source_id = ids[0].id;
				CloseWindow(ids[0].id);
			}
		}
		
		function CloseWindow(action) {
			if (window.CloseOwnerWindow){
				return window.CloseOwnerWindow(action);
			}else{
				window.close();
			}
		}
		function onOk() {
			//commitTask();
			}
		function onCancel() {
			CloseWindow("cancel");
		}
	</script>
</body>
</html>